package run.scenario;

import static log.LogConstants.*;
import static run.scenario.GeneratorConstants.COMMENT;
import static run.scenario.GeneratorConstants.ExpName;
import static run.scenario.GeneratorConstants.LN;
import static run.scenario.GeneratorConstants.SEPARATOR;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;

import log.LogConstants;

import run.ScenarioManager;

public class ScenarGenerator {
	
	public static final int VALUE = 0;
	public static final int NAME = 1;
	
	public static final String EXPE_NAME = "Tap Study";
	protected static BufferedWriter writer;
	
	// Unused for now
	public static final int NbSujets = 80;
	
	// Unused for now
	public static final int NB_NAMING = 16;
	
	public static final boolean VERBOSE = true;
	
	public static void speak(String s) {
		if (VERBOSE)
			System.out.println(s);
	}
	
	public static final String[] ValeursHands = new String[] {	
		"Left",
		"Right"
	};
	
	public static final String[] ValeursTasks = {
		"Baseline 1",
		LogConstants.Reading,
		"Counting",
		"Baseline 2"
	};
	
	public static void main(String[] args) {
		
		try {
			
			writer = new BufferedWriter(new FileWriter("experiment_tap.txt"));
			
			/*
			 * Constants
			 */
			
			appendln(ExpName, EXPE_NAME);
			appendln(NbTrials, ""+(ValeursHands.length * ValeursTasks.length));
			
			appendln(Block, "1");
			
			int trial = 1;
			
			for (int task = 0 ; task < ValeursTasks.length ; task++) {
				
				for (int hand = 0 ; hand < ValeursHands.length ; hand++) {
					
					appendln(Trial, ""+trial, 
							Task, ValeursTasks[task],
							Hand, ValeursHands[hand]);
					
					trial++;
					
				}
				
			}
			
			writer.close();
			
			System.out.println("OK");
			
			
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	protected static void appendln(String... data) {
		
		try {
			
			for (int i = 0 ; i < data.length - 1 ; i++) {
				
				writer.append(data[i]);
				writer.append(SEPARATOR);
				
			}
			
			writer.append(data[data.length - 1]);
			writer.append(LN);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	protected static void comment(String comment) {
		try {
			writer.append(COMMENT + comment + LN);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
}
